﻿namespace DreamBuilder.Common
{
    using System;

    public class CStringFormat
    {
        public static string HTMLDecode(string str)
        {
            short num = 13;
            str = str.Replace("’", "'");
            str = str.Replace("&amp;", "&");
            str = str.Replace("&lt;", "<");
            str = str.Replace("&gt;", ">");
            str = str.Replace("&quot;", "\"");
            str = str.Replace("<br>", ((char) ((ushort) num)).ToString());
            return str;
        }

        public static string HTMLEncode(string str)
        {
            short num = 13;
            str = str.Replace("'", "’");
            str = str.Replace("&", "&amp;");
            str = str.Replace("<", "&lt;");
            str = str.Replace(">", "&gt;");
            str = str.Replace("\"", "&quot;");
            str = str.Replace(((char) ((ushort) num)).ToString(), "<br>");
            return str;
        }

        public static string SqlStrFormat(string strSql)
        {
            if (strSql == "")
            {
                return "";
            }
            strSql = strSql.Replace("'", "''");
            strSql = strSql.Replace("[", "[[]");
            strSql = strSql.Replace("%", "[%]");
            strSql = strSql.Replace("_", "[_]");
            strSql = strSql.Replace("*", "[*]");
            return strSql;
        }

        public static string SqlStrFormat2(string strSql)
        {
            if (strSql == "")
            {
                return "";
            }
            strSql = strSql.Replace("'", "''");
            return strSql;
        }
    }
}

